<!doctype html>
<html lang="zh">
<head>
	<meta charset="UTF-8">
	<meta name="viewport" content="width=device-width, initial-scale=1" />
	<title>test</title>
	<script src="http://libs.useso.com/js/jquery/2.1.1/jquery.min.js"></script>
	<link rel="stylesheet" type="text/css" href="rsc/base.css" />
</head>

<?php require_once('config.php'); ?>
<?
$book=intval($_GET['book']);
if ($bookarr[$book]===null) {
	echo '<script>alert("从头开始~!");</script>';
	$book=1;
};

$raw=file_get_contents('data/'.$book.'.txt');
$raw=trim($raw);
$raw=str_replace("\r",'',$raw);
$raw=explode("\n",$raw);

/*
//方案一、按行
for($i=0;$raw[$i];$i++) {
	$raw[$i]=trim($raw[$i]);
	$raw[$i]=explode('###',$raw[$i]);
};
*/

//方案二、全部合并
for($i=0;$i<count($raw);$i++){
	$raw[$i]='◆'.$raw[$i];
};
$raw=implode('###',$raw);
$raw=explode('###',$raw);
$raw=array_filter($raw);
$raw=array_values($raw);
//print_r($raw);
$json=json_encode($raw);
$json=str_replace('<br\/>','<br/>',$json);
//echo '<TEXTAREA>'.json_encode($raw).'</TEXTAREA>';


$phpself=$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
?>

<script>
var fromphp = new Array();
fromphp[0]='<? echo $json; ?>';
fromphp[1]='<? echo $phpself; ?>';
fromphp[2]=<? echo $book; ?>;
fromphp[3]=<? echo intval($_GET['x']); ?>;
</script>



<body>

<div id="unavi">
	<div id="unavitog">显示/隐藏快速跳课导航</div>
	<div id="unavicon" style="display:none;">
		<span style="">
<?php foreach ($bookarr as $id=>$name) { ?>
			<a href="?book=<?php echo $id; ?>"><?php echo $name; ?></a>
<?php }; ?>
		</span>
	</div>
</div>

<div id="main"><span id="mainled"></span></div>

<div id="back">←BACK　<small>(存书签以保存进度)</small></div>

<div id="control">
	<button id="selectsw">文字选择：开</button>
	<button id="taller">增加高度</button>
	<button id="shorter">降低高度</button>
	<button id="night">切换主题</button>
	<button id="bigger">字体加大</button>
	<button id="smaller">字体缩小</button>
</div>

</body>

<script src="rsc/main.js"></script>

</html>